<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
    <title>当前位置</title>
    <style>
      html,
      body,
      div {
        margin: 0;
        padding: 0;
      }

      html,
      body,
      #container {
        width: 100%;
        height: 100%;
      }
    </style>
  </head>
  <body>
    <div id="container"></div>

    <script type="text/javascript">
      window._AMapSecurityConfig = {
      //2813c576d21d9432adf0a747a789a409
        securityJsCode: "ba60e2fcdc15dfb63af7da50f2c1f125",
      };
    </script>
    <script src="https://webapi.amap.com/loader.js"></script>
    <script type="text/javascript">
        const GET = {}
        location.search.replace(/([^?&=]+)=([^&]+)/g, (_, k, v) => (GET[k] = v))
        GET.latitude = '114.441862'
        GET.longitude = '30.462086'
        if(GET.latitude&&GET.longitude){
          AMapLoader.load({
            key: "345b4b5593d2fa2707ce7fb6a539a569", //申请好的Web端开发者key，调用 load 时必填
            version: "2.0", //指定要加载的 JS API 的版本，缺省时默认为 1.4.15
          })
            .then((AMap) => {
              //JS API 加载完成后获取AMap对象
               const map = new AMap.Map("container", {
                mapStyle: "amap://styles/macaron", //设置地图的显示样式
                center: [GET.latitude, GET.longitude], //地图中心点
               layers: [new AMap.TileLayer.Satellite()],
               zoom: 16
              })

              // 设置经纬度
              const position = new AMap.LngLat(GET.latitude, GET.longitude)
              // 定位图标
              const location = new AMap.Marker({
                position: position,
                icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
                offset: new AMap.Pixel(-13, -30),
              })
              map.add(location)
            })
            .catch((e) => {
              console.error(e) //加载错误提示
            })
        }
    </script>
  </body>
</html>
